<template>
  <div class="container">
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item label="测试卷">
        <el-input v-model="form.user" placeholder="测试卷" clearable />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="findTestList">查询</el-button>
      </el-form-item>
    </el-form>
    <div :class="testList.length > 0 ? '' : 'noList'" class="test-list">
      <Paper v-for="(test, i) in testList" :key="i" :test="test" class="paper" @findTestList="findTestList" />
    </div>
    <el-empty :class="testList.length === 0 ? '': 'noList'" description="没有测试卷......" />
  </div>
</template>

<script>
import Paper from './paper.vue'
import { findTestList } from '@/api/test'
export default {
  components: { Paper },
  data() {
    return {
      form: {
        user: ''
      },
      testList: []
    }
  },
  mounted() {
    this.findTestList()
  },
  methods: {
    findTestList() {
      findTestList({ name: this.form.user }).then(res => {
        this.testList = res.data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.container{
  padding: 20px;
}
.noList{
  display: none;
}
.paper{
  float: left;
  margin-left: 20px;
}
</style>
